package com.linx.kafka;

import com.linx.common.core.constant.KafkaReportType;
import com.linx.common.log.constant.LogType;
import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Profile;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.kafka.support.Acknowledgment;
import org.springframework.stereotype.Component;

/***
 * @ClassName KafkaConsumer
 * @Description TODO
 * @Author gushaoliang
 * @Date 2024/11/27 上午11:35
 * @Version 1.0
 */
@Component
@Profile({"test", "prod"})
//@Profile({"!dev"})
public class KafkaConsumer {

    private final Logger kafkaLog = LoggerFactory.getLogger(LogType.KAFKA);

    /**
     * 正元门锁
     */
    @KafkaListener(topics ="JTWL-KM-IIOT-ZYMS")
    public void zyms(ConsumerRecord<?,String> record, Acknowledgment acknowledgment){
        kafkaLog.info("收到主题JTWL-KM-IIOT-ZYMS的消息（正元门锁）：{}", record);

        // 确认消息已被消费
        acknowledgment.acknowledge();
    }


}

